-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Check on Ellipsis in format
#726
base: main
Are you sure you want to change the base?
Conversation
The use of `rlang::check_dots_empty` in `format_tbl` threw an error when arguments were passed via `...`. This behaviour seems unintended, as we deliberately pass `...` down to `tbl_format_setup`. In this fix, we replace `rlang::check_dots_empty` with `rlang::check_dots_used` to ensure that all arguments passed to `format` (or `print`, for that matter) are utilized. This change prevents dangling arguments while allowing authors to add new arguments to their print functions. A dedicated test case was added to `test-tbl-format.R`. We used `withr::with_environment` to ensure that the temporary `tbl_format_setup.my_tibble` method can be properly dispatched.
Ok, I see that the added test cases fails (it passes locally for whatever obscure reason). It must have something to do with he availability of |
In the previous commit, we included a test case for checking the ellipsis in `format`. While the test passed on the local system, it failed on the remote system. The reason is most likely the availability of the S3 method `tbl_format_setup.my_tibble`. We already needed a special `withr::with_environment` construct locally to make the test pass. However, this does not properly guarantee availability on the remote system. Thus, we simply removed the specialized test case for a custom class and only show the basic case where we expect an error, but not the case where we do not expect an error.
@lionel-: Do you think this is a good use case for |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense!
Should probably document in ?print.tbl
(top of that file) that ... is passed down to
tbl_format_setup()(both from
print()and from
format()`)
@@ -77,3 +77,10 @@ test_that("get_width_print()", { | |||
expect_equal(get_width_print(80), 80) | |||
expect_equal(get_width_print(140), 140) | |||
}) | |||
|
|||
test_that("format() signals an error if not all arguments in `...`are used", { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe add a motivating test case for passing down an argument to a tbl_format_setup()
method?
The use of
rlang::check_dots_empty
informat_tbl
threw an error when arguments were passed via...
. This behaviour seems unintended, as we deliberately pass...
down totbl_format_setup
.In this fix, we replace
rlang::check_dots_empty
withrlang::check_dots_used
to ensure that all arguments passed toformat
(orprint
, for that matter) are utilized. This change prevents dangling arguments while allowing authors to add new arguments to their print functions.A dedicated test case was added to
test-tbl-format.R
. We usedwithr::with_environment
to ensure that the temporarytbl_format_setup.my_tibble
method can be properly dispatched.